#include "widget.h"
#include "ui_widget.h"

#include <QDebug>
#include <QButtonGroup>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

//   // 默认选择男
//   ui->radioButton_man->setCheckable(true);
//   ui->radioButton_man->setChecked(true);
   ui->label->setText("你选择的性别为：男");

//   // 禁用其他按钮
//   ui->radioButton_other->setCheckable(false);
//   // 更加彻底的禁用方式
//   ui->radioButton_other->setEnabled(false);

   ui->radioButton_1->setAutoExclusive(false);
   ui->radioButton_2->setAutoExclusive(false);


   // 单选框分组
   QButtonGroup* group1 = new QButtonGroup(this);
   QButtonGroup* group2 = new QButtonGroup(this);
   QButtonGroup* group3 = new QButtonGroup(this);

   group1->addButton(ui->radioButton_10);
   group1->addButton(ui->radioButton_5);

   group2->addButton(ui->radioButton_6);
   group2->addButton(ui->radioButton_7);

   group3->addButton(ui->radioButton_8);
   group3->addButton(ui->radioButton_9);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_radioButton_1_clicked()
{
    qDebug() << "clicked";
}

void Widget::on_radioButton_2_pressed()
{
    qDebug() << "pressed";
}

void Widget::on_radioButton_3_released()
{
    qDebug() << "released";
}

void Widget::on_radioButton_4_toggled(bool checked)
{
    if(checked)
    {
        qDebug() << "toggled checked true";
    }
    else
    {
        qDebug() << "toggled checked false";
    }
}


void Widget::on_radioButton_man_clicked()
{
    ui->label->setText("你选择的性别为：男");
}

void Widget::on_radioButton_female_clicked()
{
    ui->label->setText("你选择的性别为：女");
}

void Widget::on_radioButton_other_clicked()
{
    ui->label->setText("你选择的性别为：其他");
}
